<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .tab ul {
            overflow: hidden;
            display: flex;
        }
        
        .tab ul>li {
            margin: 0;
            padding: 0;
            list-style: none;
            width: 70px;
            height: 45px;
            line-height: 45px;
            text-align: center;
            box-sizing: border-box;
            border: 1px solid rebeccapurple;
            cursor: pointer;
        }
        
        .tab ul li:first-child {
            border-left: 1px solid blue;
        }
        
        .tab ul li.active {
            background-color: orange;
        }
        
        .tab div {
            width: 210px;
            height: 150px;
            display: none;
            text-align: center;
            font-size: 30px;
            line-height: 300px;
            border-top: 0px;
        }
        
        .tab div.current {
            display: block;
        }
        
        .tab .box {
            position: relative;
            display: flex;
        }
        
        .box div {
            position: absolute;
            left: 40px;
            top: -27px;
        }
        
        img {
            width: 210px;
            height: 150px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="tab">
            <ul>
                <li v-on:click='change(index)' :class='currentIndex==index?"active":""' :key='item.id' v-for='(item,index) in list'>{{item.title}}</li>
            </ul>
            <div class="box">
                <div :class='currentIndex==index?"current":""' :key='item.id' v-for='(item,index) in list'>
                    <img :src="item.path">
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript">
        var m = new Vue({
                el: '#app',
                data: {
                    currentIndex: 0, //选项卡当前的索引
                    list: [{
                        id: 1,
                        title: 'apple',
                        path: './img/01.jpg'
                    }, {
                        id: 2,
                        title: 'orange',
                        path: './img/02.jpg'
                    }, {
                        id: 3,
                        title: 'banana',
                        path: './img/03.jpg'
                    }]
                },
                methods: {
                    change: function(index) {
                        // 这里实现选项卡切换操作，操作类名，通过索引值变化
                        this.currentIndex = index;
                    }
                }
            })
            // 声明式编程：
            //   模板的结构和最终显示的效基本一致
    </script>
</body>

</html>